# 作者：薛丰坤
# 2025年06月04日20时30分12秒
# 2634661037@qq.com
# 士兵突击
# 开发枪类
class Gun:
    def __init__(self, model):
        # 枪的型号
        self.model = model
        # 子弹数量
        self.bullet_count = 0

    def add_bullet(self, count):
        self.bullet_count += count

    def shoot(self):
        # 判断是否还有子弹
        if self.bullet_count <= 0:
            print("没有子弹了...")
            return

        # 发射一颗子弹
        self.bullet_count -= 1

        print("%s 发射子弹[%d]..." % (self.model, self.bullet_count))


class Soldier:
    def __init__(self, name):
        self.name = name
        self.gun = None

    def fire(self):
        if self.gun is None:
            print("[%s 还没有枪...]" % self.name)

            return
        print("冲啊...[%s]" % self.name)

        self.gun.add_bullet(50)

        self.gun.shoot()


# 实例化
ak47 = Gun("AK47")
xusanduo = Soldier("许三多")
xusanduo.gun = ak47
xusanduo.fire()
print(xusanduo.gun)
ak47.add_bullet(50)
ak47.shoot()